<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .tp1 {
            background-image: url(https://img0.baidu.com/it/u=857510153,4267238650&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=675);
            /* background-size: 100vw 100vh; */
        }
        
        .tp2 {
            background-image: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F2109242326224L3-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647650650&t=1cdb58839cd1a4138cbecbbbbc3d872f);
            /*  background-size: 100vw 100vh; */
        }
    </style>
</head>

<body>
    <button>按钮一</button>
    <button>按钮二</button>
    <script>
        var btn = document.querySelectorAll("button");
        console.log(btn);

        for (let i = 0; i < btn.length; i++) {
            btn[i].onclick = function() {
                /* console.log(i); */

                document.body.className = `tp${1 + i}`;
            };
        }
    </script>
</body>

</html>